{php include wl_template('common/header');}
<script type="text/javascript" src="{URL_WEB_JS}diyarea.js"></script>
<style>
    #memberInfo .form-group{
        margin-bottom: 10px!important;
    }
    #memberInfo .img-photo{
        max-width: 150px;
        max-height: 150px;
        float:left;
        margin:2px;
    }
    #memberInfo video{
        height: 300px!important;
        width: auto!important;
        border: 1px solid #ddd;
        padding: 5px;
    }
    .margin-r-5{
        margin-right: 5px;
    }
</style>
<ul class="nav nav-tabs" id="myTab">
    <li class="active"><a href="#tab_basic">基础信息</a></li>
    <li><a href="#tab_more">更多信息</a></li>
    <li><a href="#tab_mark">营销设置</a></li>
    <li><a href="#tab_settlement">分销结算</a></li>
</ul>

<div class="app-content">
    <div class="app-form" id="memberInfo">
        <form class="form-horizontal form form-validate" method="post">
            <div class="tab-content">
                <!-- 基本信息 -->
                <div class="tab-pane active" id="tab_basic">
                    <div class="panel panel-default">
                        <div class="panel-heading">基本信息</div>
                        <div class="panel-body">
                            <div class="form-group" >
                                <label class="col-sm-2 control-label">所属酒店</label>
                                <div class="col-sm-9">
                                    <div class='input-group'>
                                        <div class="input-group ">
                                            <input type="text" class="form-control col-sm-9" id="namemerchant" name="" value="{$info['storename']}" style="width: 460px;" disabled>
                                            <span class="input-group-btn">
                                                    <button class="btn btn-default" type="button" onclick="popwin = $('#modal-module-merchant').modal();">选择商家</button></span>
                                        </div>
                                        <div class="input-group " style="margin-top:.5em;">
                                            <input type="hidden" value="{$info['sid']}" name="info[sid]" id="sidmerchant" >
                                            <img src="{if empty($info['storelogo'])}../web/resource/images/nopic.jpg{else}{php echo tomedia($info['storelogo'])}{/if}" class="img-responsive img-thumbnail" width="150" id="imgmerchant" />
                                            <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除" onclick="remove_merchant(this)">×</em>
                                        </div>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间标题<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <input class="form-control" required type="text" name="info[name]" value="{$info['name']}"  />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间缩略图<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    {php echo attachment_select('info[thumb]', $info['thumb'])}
                                    <div class="help-block">用户房间列表显示，建议使用正方形图片。</div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">图集<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    {php echo attachment_select_multi('info[images]',$info['images']);}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间类型</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="info[roomtype]" onclick="$('#hour').html('每天');$('#roomtype1').show();$('#roomtype2').hide();$('#roomnum').show();" value="1" {if $info['roomtype']==1 || empty($info['roomtype'])}checked{/if}> 单间
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[roomtype]" onclick="$('#hour').html('每天');$('#roomtype1').hide();$('#roomtype2').show();$('#roomnum').show();" value="2" {if $info['roomtype']==2}checked{/if}> 套房
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[roomtype]" onclick="$('#hour').html('每小时');$('#roomtype1').show();$('#roomtype2').hide();$('#roomnum').hide();" value="3" {if $info['roomtype']==3}checked{/if}> 钟点房
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间价格<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <span class="input-group-addon">￥</span>
                                        <input class="form-control" min="0" required type="number" name="info[price]" value="{$info['price']}"  />
                                        <span class="input-group-addon" id="hour"  >{if  $info['roomtype']!=3 }每天{else}每小时{/if}</span>
                                    </div>
                                    <div class="help-block">价格最多保留两位小数。</div>
                                </div>
                            </div>

                            <div class="form-group" id="roomnum" {if $info['roomtype'] == 3 } style="display: none;"  {/if} >
                                <label class="col-sm-2 control-label">房间数量<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <input class="form-control" min="0" required type="number" name="info[roomnum]" value="{$info['roomnum']}"  />
                                    </div>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">状态</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="info[status]" value="1" {if $info['status']==1}checked{/if}> 上架中
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[status]" value="0" {if $info['status']!=1}checked{/if}> 已下架
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">排序</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="number" name="info[sort]" value="{$info['sort']}"  />
                                    <div class="help-block">列表排序参数。数字越大越靠前。</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="tab-pane" id="tab_more">
                    <div class="panel panel-default">
                        <div class="panel-heading">更多信息</div>
                        <div class="panel-body">

                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间面积<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <input class="form-control"  required type="number" min="0"  name="info[size]" value="{$info['size']}"  />
                                        <span class="input-group-addon">㎡</span>
                                    </div>
                                </div>
                            </div>

                            <div class="form-group" id="roomtype2" {if $info['roomtype'] != 2 } style="display: none;"  {/if}>
                                <label class="col-sm-2 control-label">套房房间<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <input class="form-control"  required type="number" min="0"  name="suite[room]" value="{$suite['room']}"  />
                                        <span class="input-group-addon">室</span>
                                        <input class="form-control" type="number" min="0"  name="suite[office]" value="{$suite['office']}"  />
                                        <span class="input-group-addon">厅</span>
                                        <input class="form-control" type="number" min="0"  name="suite[wei]" value="{$suite['wei']}"  />
                                        <span class="input-group-addon">卫</span>
                                        <input class="form-control" type="number" min="0"  name="suite[kitchen]" value="{$suite['kitchen']}"  />
                                        <span class="input-group-addon">厨</span>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group" id="roomtype1" {if $info['roomtype'] == 2 } style="display: none;"  {/if}>
                                <label class="col-sm-2 control-label">床位数量<span class="form-must">*</span></label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <input class="form-control"  required type="number" min="0"  name="info[bednum]" value="{$info['bednum']}"  />
                                        <span class="input-group-addon">张</span>
                                    </div>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">免费早餐</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="info[breakfast]" value="1" {if $info['breakfast']==1}checked{/if}> 有
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[breakfast]" value="0" {if $info['breakfast']!=1}checked{/if}> 无
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间阳台</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline">
                                        <input type="radio" name="info[balcony]" value="1" {if $info['balcony']==1}checked{/if}> 有
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" name="info[balcony]" value="0" {if $info['balcony']!=1}checked{/if}> 无
                                    </label>
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间设施</label>
                                <div class="col-sm-9">
                                    {loop $facilities $fac}
                                    <label class="checkbox-inline">
                                        <input type="checkbox" value="{$fac['id']}" name="facilities[]"  {if in_array($fac['id'],$info['facilities'])}checked="checked"{/if} /> {$fac['title']}
                                    </label>
                                    {/loop}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间服务</label>
                                <div class="col-sm-9">
                                    {loop $service $serv}
                                    <label class="checkbox-inline">
                                        <input type="checkbox" value="{$serv['id']}" name="service[]"  {if in_array($serv['id'],$info['service'])}checked="checked"{/if} /> {$serv['title']}
                                    </label>
                                    {/loop}
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间描述</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="text" name="info[roomdesc]" value="{$info['roomdesc']}"  />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">特别提醒</label>
                                <div class="col-sm-9">
                                    <input class="form-control" type="text" name="info[remind]" value="{$info['remind']}"  />
                                </div>
                            </div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">房间押金</label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <input type="number" min="0" name="info[deposit]" class="form-control " value="{$info['deposit']}" />
                                        <span class="input-group-addon">元</span>
                                    </div>
                                    <div class="help-block">不填或填0时房间不收取押金。</div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="tab-pane" id="tab_mark">
                    <div class="panel panel-default">
                        <div class="panel-heading">营销设置</div>
                        <div class="panel-body">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">会员优惠</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline" onclick="$('#vipprice').hide();$('#viplevel').hide();" >
                                        <input type="radio" value="0" name="info[vipstatus]" {if $info['vipstatus']==0} checked {/if}>无
                                    </label>
                                    <label class="radio-inline" onclick="$('#vipprice').show();$('#viplevel').hide();">
                                        <input type="radio" value="1" name="info[vipstatus]" {if $info['vipstatus']==1} checked {/if}>会员减免
                                    </label>
                                    <label class="radio-inline" onclick="$('#vipprice').hide();$('#viplevel').show();">
                                        <input type="radio" value="2" name="info[vipstatus]" {if $info['vipstatus']==2} checked {/if}>会员特供
                                    </label>
                                    <span class="help-block">房间的会员优惠设置，会员特供即只有会员可以下单。</span>
                                </div>
                            </div>
                            <div class="form-group" id="vipprice" {if $info['vipstatus'] != 1} style="display: none;"  {/if}>
                                <label class="col-sm-2 control-label">减免金额</label>
                                <div class="col-sm-9">
                                    <div class="bigdata" style="margin-top: 10px;">
                                        <div class="input-group data-item">
                                            <span class="input-group-addon">[{$_W['wlsetting']['halflevel']['name']}]减</span>
                                            <input type="hidden" name="vipleid[]" class="form-control" value="0">
                                            <input type="number" min="0" name="vipprice[]" class="form-control" value="{$viparray[0]['vipprice']}">
                                            {if is_store() }
                                            <span class="input-group-addon">元(最多保留两位小数)</span>
                                            {else}
                                            <span class="input-group-addon">元,商户减少结算价</span>
                                            <input type="number" min="0" name="storeset[]" class="form-control" value="{$viparray[0]['storeset']}">
                                            <span class="input-group-addon">元(最多保留两位小数)</span>
                                            {/if}
                                        </div>
                                    </div>
                                    {loop $levels $lpr}
                                    <div class="bigdata" style="margin-top: 10px;">
                                        <div class="input-group data-item">
                                            <span class="input-group-addon">[{$lpr['name']}]减</span>
                                            <input type="hidden" name="vipleid[]" class="form-control" value="{$lpr['id']}">
                                            <input type="number" min="0" name="vipprice[]" class="form-control" value="{$viparray[$lpr['id']]['vipprice']}">
                                            {if is_store()}
                                            <span class="input-group-addon">元(最多保留两位小数)</span>
                                            {else}
                                            <span class="input-group-addon">元,商户减少结算价</span>
                                            <input type="number" min="0" name="storeset[]" class="form-control" value="{$viparray[$lpr['id']]['storeset']}">
                                            <span class="input-group-addon">元(最多保留两位小数)</span>
                                            {/if}
                                        </div>
                                    </div>
                                    {/loop}
                                </div>
                            </div>

                            <div class="form-group" id="viplevel"   {if $info['vipstatus'] != 2} style="display: none;"  {/if}>
                                <label class="col-sm-2 control-label">适用会员等级</label>
                                <div class="col-sm-9">
                                    <label class="checkbox-inline">
                                        <input type="checkbox" value="0" {if in_array(0,$info['level'])} checked {/if}  name="level[]" />{$_W['wlsetting']['halflevel']['name']}
                                    </label>
                                    {loop $levels $level}
                                    <label class="checkbox-inline">
                                        <input type="checkbox" value="{$level['id']}" {if in_array($level['id'],$info['level'])} checked {/if}  name="level[]" />{$level['name']}
                                    </label>
                                    {/loop}
                                    <span class="help-block">如果全都不勾选则默认全等级可用</span>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-2 control-label">积分抵扣</label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <span class="input-group-addon">每件商品可以使用积分抵扣</span>
                                        <input type="number" min="0" name="info[creditmoney]" class="form-control " value="{$info['creditmoney']}" />
                                        <span class="input-group-addon">元</span>
                                    </div>
                                    <div class="help-block">不填或填0时将不参加积分抵扣</div>
                                </div>
                            </div>

                            {if !empty($fullreducelist)}
                            <div class="form-group">
                                <label class="col-sm-2 control-label">满减活动</label>
                                <div class="col-sm-9">
                                    <select name="info[fullreduceid]" class="form-control chosen-select">
                                        <option value="" {if empty($info['fullreduceid'])}selected="selected"{/if}>请选择满减活动</option>
                                        {loop $fullreducelist $full}
                                        <option value="{$full['id']}" {if $info['fullreduceid'] == $full['id']}selected="selected"{/if}>{$full['title']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                            {/if}
                            {if !empty($paidlist) && !is_store()}
                            <div class="form-group">
                                <label class="col-sm-2 control-label">支付有礼</label>
                                <div class="col-sm-9">
                                    <select name="info[paidid]" class="form-control chosen-select">
                                        <option value="" {if empty($info['paidid'])}selected="selected"{/if}>请选择支付有礼活动</option>
                                        {loop $paidlist $paid}
                                        <option value="{$paid['id']}" {if $info['paidid'] == $paid['id']}selected="selected"{/if}>{$paid['title']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                            {/if}
                            {if !empty($drawlist) && !is_store()}
                            <div class="form-group">
                                <label class="col-sm-2 control-label">锦鲤抽奖</label>
                                <div class="col-sm-9">
                                    <select name="info[drawid]" class="form-control chosen-select">
                                        <option value="" {if empty($info['drawid'])}selected="selected"{/if}>请选择锦鲤抽奖活动</option>
                                        {loop $drawlist $drid}
                                        <option value="{$drid['id']}" {if $info['drawid'] == $drid['id']}selected="selected"{/if}>{$drid['title']}</option>
                                        {/loop}
                                    </select>
                                </div>
                            </div>
                            {/if}
                        </div>
                    </div>
                </div>



                <div class="tab-pane" id="tab_settlement">
                    <div class="panel panel-default">
                        <div class="panel-heading">分销结算</div>
                        <div class="panel-body">
                            {if !is_store()}
                            <div class="form-group">
                                <label class="col-sm-2 control-label">商品独立结算</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline" onclick="indepen(1)">
                                        <input type="radio" value="1" name="info[independent]" {if $info['independent'] == 1} checked {/if}>开启
                                    </label>
                                    <label class="radio-inline" onclick="indepen(0)">
                                        <input type="radio" value="0" name="info[independent]" {if $info['independent'] == 0} checked {/if}>关闭
                                    </label>
                                </div>
                            </div>
                            <div class="form-group" id="indediv" {if $info['independent'] == 0} style="display: none;" {/if}  >
                                <label class="col-sm-2 control-label">结算金额</label>
                                <div class="col-sm-9">
                                    <div class="input-group">
                                        <span class="input-group-addon">结算价</span>
                                        <input type="number" min="0" name="info[settlementmoney]" class="form-control " value="{$info['settlementmoney']}" />
                                        <span class="input-group-addon">元</span>
                                    </div>
                                    <div class="help-block">在用户核销以后，自动打入商家帐户余额，最多保留两位小数</div>
                                </div>
                            </div>
                            {/if}

                        {if $distriset['switch']}
                        <div class="form-group">
                            <label class="col-sm-2 control-label">是否参与分销</label>
                            <div class="col-sm-9">
                                <label class="radio-inline" onclick="distri(1)">
                                    <input type="radio" value="1" name="info[isdistri]" {if $info['isdistri']==1 } checked {/if}>参与
                                </label>
                                <label class="radio-inline" onclick="distri(2)">
                                    <input type="radio" value="0" name="info[isdistri]" {if $info['isdistri']==0 } checked {/if}>不参与
                                </label>
                            </div>
                        </div>
                        <div id="distridiv" {if $info['isdistri'] == 0} style="display: none;" {/if} >
                            <div class="form-group">
                                <label class="col-sm-2 control-label">佣金设置方式</label>
                                <div class="col-sm-9">
                                    <label class="radio-inline" onclick="distritext(1)" >
                                        <input type="radio"  name="info[isdistristatus]" value="0" title="百分比" {if $info['isdistristatus'] == 0 || empty($info['isdistristatus'])}checked{/if}>百分比
                                    </label>
                                    <label class="radio-inline" onclick="distritext(2)" >
                                        <input type="radio"  name="info[isdistristatus]" value="1" title="固定金额" {if $info['isdistristatus'] == 1}checked{/if}>固定金额
                                    </label>
                                    <span class="help-block">按百分比计算时，基础价按照商品售价减去会员减免计算，不受积分抵扣，满减活动，在线红包影响。</span>
                                </div>
                            </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">分销佣金详情</label>
                                    <div class="col-sm-9">
                                        {loop $dislevel $dislpr}
                                        <div class="bigdata" style="margin-top: 10px;">
                                            <div class="input-group data-item">
                                                <span class="input-group-addon">[{$dislpr['name']}]一级</span>
                                                <input type="hidden" name="disleid[]" class="form-control" value="{$dislpr['id']}">
                                                <input type="number" min="0" name="onedismoney[]" class="form-control" value="{$disarray[$dislpr['id']]['onedismoney']}">
                                                <span class="input-group-addon"><span class="isdistritext">{if $info['isdistristatus'] == 1}元{else}%{/if}</span>,二级</span>
                                                <input type="number" min="0" name="twodismoney[]" class="form-control" value="{$disarray[$dislpr['id']]['twodismoney']}">
                                                <span class="input-group-addon"><span class="isdistritext">{if $info['isdistristatus'] == 1}元{else}%{/if}</span>(最多保留两位小数)</span>
                                            </div>
                                        </div>
                                        {/loop}
                                        <span class="help-block">一级填0或不填则按分销商等级默认比例计算,填写一级佣金后二级佣金填0或不填则此商品没有二级分佣,最多保留两位小数</span>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">分销佣金结算时间</label>
                                    <div class="col-sm-9">
                                        <label class="radio-inline">
                                            <input type="radio" value="0" name="info[dissettime]" {if $info['dissettime']==0 || empty($info['dissettime'])} checked {/if}>订单完成时结算
                                        </label>
                                        <label class="radio-inline">
                                            <input type="radio" value="1" name="info[dissettime]" {if $info['dissettime']==1 } checked {/if}>订单支付时结算
                                        </label>
                                        <span class="help-block">注：若订单支付时结算，在订单退款时会扣除分销商对应的佣金，如果分销商可提现佣金不足，会扣至负数</span>
                                    </div>
                                </div>
                            </div>
                            {/if}
                        </div>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-2 control-label"></label>
                <div class="col-sm-9">
                    <input type="submit" name="submit" value="提交" class="btn btn-primary min-width" />
                    <input type="hidden" name="token" value="{$_W['token']}" />
                    <input type="hidden" name="id" value="{$_GPC['id']}" />
                </div>
            </div>
            <div id="modal-module-merchant" class="modal fade" tabindex="-1">
                <div class="modal-dialog" style='width: 920px;'>
                    <div class="modal-content">
                        <div class="modal-header">
                            <button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button>
                            <h3>选取</h3></div>
                        <div class="modal-body">
                            <div class="row">
                                <div class="input-group">
                                    <input type="text" class="form-control" name="keyword" value="" id="search-kwd-merchant" placeholder="请输入商家名称，不输入任何内容搜索结果为所有商家。" />
                                    <span class='input-group-btn'><button type="button" class="btn btn-default" onclick="search_merchant();">搜索</button></span>
                                </div>
                            </div>
                            <div id="module-merchant" style="padding-top:5px;"></div>
                        </div>
                        <div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a></div>
                    </div>
                </div>
            </div>


        </form>
    </div>
</div>


<script>


    function search_merchant() {
        $("#module-merchant").html("正在搜索....")
        $.get("{php echo web_url('hotel/hotel/selectMerchant')}", {
            keyword: $.trim($('#search-kwd-merchant').val())
        }, function(dat){
            $('#module-merchant').html(dat);
        });
    }
    function remove_merchant(obj){
        $('#goodsidmerchant').val('');
        $('#namemerchant').val('');
        $('#imgmerchant').attr("src",'');
        $('#sidmerchant').val('');
    }
    function select_merchant(o) {
        var lastid = $('#sidmerchant').val();
        if (lastid != o.id) {
            $('#sidmerchant').val(o.id);
            $('#namemerchant').val(o.storename);
            $('#imgmerchant').attr("src",o.logo);
            $('#modal-module-merchant').modal('hide');
        }else{
            $('#modal-module-merchant').modal('hide');
        }
    }


    function indepen(flag){
        if (flag == 1) {
            $('#indediv').show();
        } else{
            $('#indediv').hide();
        }
    }

    function distri(flag){
        if (flag == 1) {
            $('#distridiv').show();
        } else{
            $('#distridiv').hide();
        }
    }

    function distritext(flag){
        if (flag == 1) {
            $('.isdistritext').html('%');
        } else{
            $('.isdistritext').html('元');
        }
    }


</script>

{php include wl_template('common/footer');}
